<template>
  <div class="friend-list">
    <div v-for="friend in friends" :key="friend.id" class="friend-item">
      <a-avatar :src="friend.avatar" />
      <span class="friend-name">{{ friend.name }}</span>
      <a-button type="link" @click="viewProfile(friend.id)">查看</a-button>
    </div>
  </div>
</template>

<script>
export default {
  name: 'FriendList',
  props: {
    friends: {
      type: Array,
      default: () => []
    }
  },
  methods: {
    viewProfile(friendId) {
      this.$router.push(`/user/${friendId}`);
    }
  }
}
</script>

<style scoped>
.friend-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.friend-item {
  display: flex;
  align-items: center;
  padding: 8px;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.friend-name {
  flex: 1;
  margin-left: 12px;
}
</style>
